<include file="Public:header" />
<div class="page-member subpage">
    <div class="form-header">
        <div>
            <div class="line1">
                <div class="fl"><h3>预缴租金详情 / {$prepay.name}（{$prepay.state}）</h3></div>
                <div class="fr hidden">
                    <form class="search-form" method="post" action="">
                        <input name="field" value="{$context.field}" type="hidden" />
                        <input name="value" value="{$context.value}" type="hidden" />
                        <input name="page" value="{$context.page}" type="hidden" />
                        <input name="order_field" value="{$context.order_field}" type="hidden" />
                        <input name="order_sort" value="{$context.order_sort}" type="hidden" />
                        <input name="offset" value="{$context.offset}" type="hidden" />
                        <input name="id" value="{$context.id}" type="hidden" />
                    </form>
                </div>
            </div>
            <div class="line2">
                <!-- 编辑按钮组 -->
                <div class="fl form-btn-group btn-group-edit">
                    <if condition="$prepay.state eq '待提交'">
                        <in name="$x|default='02-01-12'" value="$rightsCode">
                            <button onclick="showDialog('dialog-prepay');" class="btn-save btn-highlight">录入票号，并提交</button>
                            <span>或</span>
                            <a onclick="action_edit();" class="linkBtn btn-abort" href="javascript:void(0);">编辑</a>
                            <else />
                            <button disabled="disabled" class="btn-save btn-disable">录入票号，并提交</button>
                        </in>
                    </if>
                    <if condition="$prepay.state eq '已提交'">
                        <in name="$x|default='02-01-13'" value="$rightsCode">
                            <button onclick="action_exit();" class="btn-save btn-highlight">退 款</button>
                            <span>或</span>
                            <a onclick="action_edit();" class="linkBtn btn-abort" href="javascript:void(0);">编辑</a>
                            <else />
                            <button disabled="disabled" class="btn-save btn-disable">退 款</button>
                        </in>
                    </if>
                </div>
                <!-- 保存按钮组 -->
                <div class="fl form-btn-group btn-group-save hidden">
                    <button onclick="action_save();" class="btn-save btn-highlight">保 存</button>
                    <span>或</span>
                    <a class="linkBtn btn-abort" onclick="action_abort();" href="javascript:void(0);">放弃</a>
                </div>
                <div class="fl form-btn-more">
                    <button class="btn-normal btn-more">
                        更多操作<i class="drop-down"></i>
                    </button>
                    <ul class="more-action hidden">
                        <li><a onclick="action_del2();" href="javascript:void(0);">删除此记录</a></li>
                    </ul>
                </div>
                <div class="fr form-search-count">
                    <span class="index">{$context.index}/{$page.total}</span>
                    <button onclick="ItemJump({$page.prev.id}, {$page.prev.offset});" class="btn-normal">上一条</button>
                    <button onclick="ItemJump({$page.next.id}, {$page.next.offset});" class="btn-normal">下一条</button>
                </div>
            </div>
        </div>
    </div>
    <div class="form-box2" style="margin-bottom:10px;">
        <div style="border-bottom:0;">
            <form id="prepayForm" method="post" action="">
                <!--表单相关原始信息存储-->
                <input type="hidden" name="old_remarks" value="{$prepay.remarks}" />
                <table class="form">
                    <tr>
                        <th width="15%">房源地址<span class="hint">*</span></th>
                        <td width="35%" field="house_addr">{$prepay.house_addr}</td>
                        <th width="15%">票号</th>
                        <td width="35%" field="invoice">{$prepay.invoice}</td>
                    </tr>
                    <tr>
                        <th width="15%">姓名<span class="hint">*</span></th>
                        <td width="35%" field="name">{$prepay.name}</td>
                        <th width="15%">身份证</th>
                        <td width="35%" field="idno">{$prepay.idno}</td>
                    </tr>
                    <tr>
                        <th>电话</th>
                        <td field="phone">{$prepay.phone}</td>
                        <th>预缴金额<span class="hint">*</span></th>
                        <td field="amount">{$prepay.amount}</td>
                    </tr>
                    <tr>
                        <th>开始日期<span class="hint">*</span></th>
                        <td field="date1">{$prepay.date1}</td>
                        <th>结束日期<span class="hint">*</span></th>
                        <td field="date2">{$prepay.date2}</td>
                    </tr>
                    <tr>
                        <th>预缴剩余金额<span class="hint">*</span></th>
                        <td name="amount_left" field="amount_left">{$prepay.amount_left}</td>
                        <th>预缴日期<span class="hint">*</span></th>
                        <td field="pdate">{$prepay.pdate}</td>
                    </tr>
                    <tr>
                        <th>备注</th>
                        <td field="remarks">{$prepay.remarks}</td>
                        <th>操作人</th>
                        <td field="cuser">{$prepay.cuser}</td>
                    </tr>
                </table>
            </form>
        </div>
    </div>
    <div class="sub-listview" style="height:270px;">
        <ul class="ui-tabs">
            <li class="selected" target="tabs-zhuhu">抵扣记录</li>
        </ul>
        <div class="tabs-item tabs-zhuhu">
            <div class="tab" style="margin-top:1px;">
                <div class="tab-head">
                    <div class="w15">抵扣事项</div>
                    <div class="w15">抵扣金额</div>
                    <div class="w15">抵扣日期</div>
                    <div class="w55">操作人</div>
                </div>
                <div class="tab-body" style="height: 280px;">
                    <volist name="plog" id="vo" key="index">
                    <div class="tab-tr">
                        <div class="w15">{$vo.name}</div>
                        <div class="w15">{$vo.amount}</div>
                        <div class="w15">{$vo.ddate}</div>
                        <div class="w55">{$vo.cuser}</div>
                    </div>
                    </volist>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="dialog-prepay dialog hidden">
    <div class="box" style="height: 200px;">
        <div class="title">
            <h4 class="fl">录入票号对话框</h4>
            <span class="fr"><a href="#" onclick="closeDialog();">关闭</a></span>
        </div>
        <table class="form-tab">
            <tr><th width="80">票号：</th>
                <td>
                    <input type="text" name="invoice_dlg" />
                    <label style="margin-left:10px;color:red;">*必填项</label>
                </td>
            </tr>
            <tr><td colspan="2" style="text-align: center;line-height:40px;">
                <button class="btn btn-highlight" onclick="action_submit();">提交</button>
                <span>或</span>
                <a href="#" onclick="closeDialog();" class="linkBtn">放弃</a>
            </td></tr>
        </table>
    </div>
</div>
<script>
    function action_exit(){
        var money = $("td[field=amount_left]").html();
        var r=confirm("您确定要退款吗？\n\r退款金额为："+money+"元");
        if (r==true){
            var dataId = $("input[name=id]").val();
            $.ajax({
                url:"/admin/prepay/ajax_exit",
                data: {id:dataId}, type:"POST", dataType:"JSON",
                success: function(data){
                    if(data.status){
                        alert("操作成功");
                        location.reload();
                    }else{
                        alert(data.info);
                    }
                }
            });
        }
    }
    function action_submit(){
        var dataId = $("input[name=id]").val();
        var invoice = $("input[name=invoice_dlg]").val();
        if(invoice.length != 10){
            alert("操作失败，票号输入有误");
            $("input[name=invoice_dlg]").focus();
            return false;
        }
        $.ajax({
            url:"/admin/prepay/ajax_submit",
            data: {id:dataId,invoice:invoice}, type:"POST", dataType:"JSON",
            success: function(data){
                if(data.status){
                    alert("操作成功");
                    location.reload();
                }else{
                    alert(data.info);
                }
            }
        });
    }
</script>
<script src="__JS__/prepay.js?v=0.3" type="text/javascript" ></script>
<include file="Public:footer" />
